package cn.com.self.apis.controller;


import cn.com.self.apis.core.vo.ResultModel;
import cn.com.self.apis.member.entity.UAccountInfo;
import cn.com.self.apis.member.entity.UReportInfo;
import cn.com.self.apis.member.entity.vo.UReportInfoVO;
import cn.com.self.apis.member.service.IAccountService;
import cn.com.self.apis.member.service.IReportInfoService;
import cn.com.self.apis.util.CopyUtils;
import cn.com.selfsoft.smartcity.commons.http.DataItem;
import cn.com.selfsoft.smartcity.commons.http.DataPage;
import cn.com.selfsoft.smartcity.commons.util.ParameterUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.Map;


/**
 *
 * @author1 ssh
 * @author2
 * @date 2021-04-28
 */
@Controller
@Api(tags = "个人中心-账号中心")
public class PersonalAccountController {

    @Autowired
    private IAccountService accountService;

    @ApiOperation(value = "根据会员id查询账号信息")
    @GetMapping("/my/account/id/{memberId}")
    public ResponseEntity getAccountById(@PathVariable("memberId") String memberId) {
        UAccountInfo accountInfo = this.accountService.queryAccountByMemberId(memberId);
        if (accountInfo != null) {
            return ResponseEntity.status(HttpStatus.OK).body(new ResultModel<>(new DataItem(accountInfo)));
        }
        return null;
    }

    /**修改账号信息
     * @Description //TODO
     * @return
     **/
    @ApiOperation(value = "修改账号信息")
    @RequestMapping(value = {"/memberInfo/updateAccount/{id}"}, method = RequestMethod.POST)
    @ResponseBody
    public ResponseEntity updateAccount(@PathVariable("id") String id, @RequestBody UAccountInfo entity, HttpServletRequest request) {
        UAccountInfo accountInfo = this.accountService.queryAccountByMemberId(id);
        CopyUtils.copyProperties(entity, accountInfo);
        entity.setId(accountInfo.getId());
        UAccountInfo update = this.accountService.update(entity);
        return ResponseEntity.status(HttpStatus.OK).body(new ResultModel<>(new DataItem(update)));

    }


}

